/**
 * // Definition for a Node.
 * function Node(val,children) {
 *    this.val = val;
 *    this.children = children;
 * };
 */

/**
 * @param {Node} root
 * @return {number}
 */
 var maxDepth = function(root) {
  if (!root) return 0
  if (!root.children) return 1
  let arr = []
  for (let item in root.children) {
    arr.push(maxDepth(root.children[item]))
  }
  return 1 + Math.max(0, ...arr)
};